import request from "@/utils/request";

/**
 * 新增权限
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function createMenu(data) {
    return request({
        url: '/sys/menu/create',
        method: 'post',
        data
    });
}

/**
 * 删除权限
 * @param uid
 * @returns {Promise<AxiosResponse<any>>}
 */
export function removeMenu(uid) {
    return request({
        url: '/sys/menu/delete/' + uid,
        method: 'get'
    });
}

/**
 * 更新权限
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export function updateMenu(data) {
    return request({
        url: '/sys/menu/update',
        method: 'post',
        data
    });
}

/**
 * 分页查询
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function queryPage(params) {
    return request({
        url: '/sys/menu/queryPage',
        method: 'get',
        params
    });
}

/**
 * 查询权限树
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function queryTreeMenu(params) {
    return request({
        url: '/sys/menu/tree',
        method: 'get',
        params
    });
}

/**
 * 查询当前角色拥有的权限
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getRoleMenu(params) {
    return request({
        url: '/sys/menu/getRoleMenu/' + params,
        method: 'get'
    });
}

/**
 * 查询当前用户拥有的权限菜单
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function getUserMenu(params) {
    return request({
        url: '/sys/menu/getUserMenu/' + params,
        method: 'get'
    });
}